<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/include/head.jsp"%>
<script type="text/javascript">
	var dialog = frameElement.dialog;
	$(function() {
		var opts = dialog.dialog("options");
		var defaultOpts = {
			title : null,
			toolbar : null,
			height : '100%',
			nowrap : false,
			striped : true,
			border : true,
			fitColumns : true,
			checkOnSelect : true,
			multiSort : true,
			queryParams:opts.param,
			collapsible : false,//是否可折叠的 
			fit : true,//自动大小 
			//sortName: 'periodType', 
			//sortOrder: 'desc', 
			remoteSort : false,
			idField : 'id',
			singleSelect : !opts.isMultiSelect,//是否单选 
			pagination : false,//分页控件 
			rownumbers : true,//行号 
			frozenColumns : [ [ {
				field : 'id',
				checkbox : true
			} ] ],
			url : 'listSendableOrderb.do',
			columns : [ [ {
				field : 'cusName',
				title : '客户名称',
				width : 100,
				sortable : true
			},{
				field : 'orderDate',
				title : '订单日期',
				width : 100,
				sortable : true,
				formatter:function(value){
		        	if(value && value.length > 10)
		        		return value.substring(0,10);
		        	else
		        		return value;
		        }
			},{
				field : 'extOrderNo',
				title : '外部订单编号',
				width : 100,
				sortable : true
			}, {
				field : 'productName',
				title : '产品名称',
				width : 100,
				sortable : true
			}, {
				field : 'productNum',
				title : '数量',
				width : 60,
				sortable : true
			}, {
				field : 'unitPrice',
				title : '单价',
				width : 60,
				sortable : true,
				formatter : function(value, row, idx) {
					if (value)
						return parseFloat(value).toFixed(2);
					return value;
				}
			}, {
				field : 'totalPrice',
				title : '总价',
				width : 80,
				sortable : true,
				formatter : function(value, row, idx) {
					if (value)
						return parseFloat(value).toFixed(2);
					return value;
				}
			},  {
				field : 'area',
				title : '收货区域',
				width : 80,
				sortable : true
			},{
				field : 'recvName',
				title : '收货单位',
				width : 100,
				sortable : true 
			}, {
				field : 'recvAdd',
				title : '收货地址',
				width : 100,
				sortable : true
			}, ] ],
			onDblClickRow : function(index, row) {

			}
		};

		$("#dg_scoredetail").datagrid(defaultOpts);
	});

	function select() {
		var opts = dialog.dialog("options");
		var selectedRow = $("#dg_scoredetail").datagrid('getChecked');
		if (selectedRow.length <= 0) {
			$.messager.alert("验证结果", "请选择数据", 'error', function() {
			});
			return;
		}
		if (selectedRow.length > 0) {
			var ids = '';
			var names = '';
			for ( var i = 0; i < selectedRow.length; i++) {
				ids += ',' + selectedRow[i].id;
				names += ',' + selectedRow[i].name;
			}
			ids = ids.substring(1);
			names = names.substring(1);
			var rows = opts.isMultiSelect ? selectedRow : selectedRow[0];
			if ($.isFunction(dialog.dialog('options').callback)) {
				dialog.dialog('options').callback({
					ids : ids,
					names : names,
					data : rows
				});
			}
		}

		closeDialog();
	}
	function closeDialog() {
		dialog.dialog('close');
	}
</script>
<div id="cc" class="easyui-layout" style="width: 100%; height: 100%;">
	<div data-options="region:'center'"
		style="padding: 5px; background: #eee; height: 200px;">
		<table id="dg_scoredetail">
		</table>
	</div>
	<div data-options="region:'south'"
		style="height: 35px; text-align: center; padding-top: 5px">
		<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
			onclick="select()">确定</a> <a href="#" class="easyui-linkbutton"
			data-options="iconCls:'icon-cancel'" onclick="closeDialog()">取消</a>
	</div>
</div>

<%@include file="/include/foot.jsp"%>